---
title: 
- Replication package for "The Economic Leverage of International Organizations in Interstate Disputes"
author: 
- Johannes Karreth
date: 
- August 3, 2017
---

# Overview

This folder contains all data and code to reproduce the analyses in "The Economic Leverage of International Organizations in Interstate Disputes" (forthcoming in International Interactions). This document makes reference to the supporting information (SI), which is part of this replication package and also posted at <http://www.jkarreth.net>. For any questions, please contact the author at <jkarreth@ursinus.edu>.

At the top level, this folder contains all R scripts necessary to:

- compile the data for analysis
- read the data into R and recode some variables for analysis
- conduct the analyses in the article

All tables and figures produced by these scripts are written to the `Output_Tables-and-Figures` folder. Full posterior distributions for all quantities estimated using MCMC are written to the `Output_MCMC` folder.

All raw datasets needed to create the data for analyses are provided in the `Sources` folder.

The `Functions` folder contains custom R functions used in this project. Where applicable, credits for code obtained from other researchers are noted at the beginning of each function.

All analyses using R were executed on R version 3.3.2 (2016-10-31) on OS X El Capitan 10.11.6; a list of packages and versions used is at the end of this file. Analyses using Stata were executed on Stata/SE 13.1 for Mac (64-bit Intel), Revision 16 Dec 2016.

### Note on reproducing exact numerical results

Most statistical analyses for this article use Bayesian estimation using Stan (via the `rstan` package in R). According to the Stan development team, different installations of Stan will produce (slightly) different draws, even if the same seed is used. This is documented in the Stan users mailing list [here](https://groups.google.com/d/topic/stan-users/qsrsvRgYOJk/discussion) (archived [here](http://www.jkarreth.net/files/Stan_Differences.pdf)). Therefore, unless you use the same operating system, version of R, and version of rstan as I used to produce these results (see the end of this file), you may obtain slightly different estimation results. These will likely show up only in postestimation quantities (e.g. first differences) and produce only minor differences. However, all estimated quantities (posterior distributions) are provided in this replication package (in the `Output_MCMC` folder) so that the numbers shown in all figures and tables can be reproduced exactly. To this end, instead of generating a model object from scratch, read the relevant object into R and execute the subsequent code. For example, in the script `12_claims_figure.R`: Instead of generating and saving `m1_stanglm` (in lines 34-42), load the stored object using this line of code: 

```
m1_stanglm <- readRDS(file = "Output_MCMC/claims_m1_stanglm.RDS")
```

and then execute the rest of the script as is.

### Note on computation time

Fitting some of the models using Bayesian estimation may take a considerable amount of time, depending on hardware specification. However, all estimated quantities (posterior distributions) are provided in this replication package (in the `Output_MCMC` folder) so that figures and tables can be reproduced without fitting each model from scratch. The section immediately above describes how to read these posterior distributions into R.

# Data sources

All data sources are documented in the SI (Table A2). The data in the "Sources" folder are either directly downloaded from their source or restructured/combined to fit the units of analysis in this project as described below:

- `atop3_0ddyr.dta`: ATOP data version 3.0
- `Dyadicdata.tab`: United Nations General Assembly Voting Data Version 17.0
- `icb1v11.csv`: International Crisis Behavior Data, crisis level
- `icbdy_v11.csv`: International Crisis Behavior Data, dyad level
- `ICOWclaimdy.dta`: ICOW Dyadic Claim-Level Summary Data
- `IGO_igounit_v2.3.narrow.csv`: COW IGO data, IGO level
- `IGO_igounit_v2.3.short.csv`: COW IGO data, IGO level
- `IGO_names_v2.3.csv`: COW IGO data, IGO names
- `IGO_stateunit_v2.3.csv`: COW IGO data, state level
- `igo.c1.diss.dta`: IGO memberships from COW, monadic level, generated by Johannes Karreth
- `igo.c2.diss.dta`: IGO memberships from COW, monadic level, generated by Johannes Karreth
- `igo.dyad.diss.dta`: IGO memberships from COW, dyadic level, generated by Johannes Karreth
- `IGOpb_dyadunit.dta`: Peace-brokering IGOs, coded from Shannon (2009)
- `igotrade.ud1918.dta`: IGO and trade data (Gleditsch 2002), undirected dyads
- `KGD_rivalry_yearly.dta`: Klein, Goertz & Diehl rivalry data
- `mtopsd150.dta`: Multilateral Treaties of Pacific Settlement (MTOPS) Data Set Version 1.4
- `NMC_v4_0.c1.dta`: COW National Material Capabilities Data Version 4.0, monadic
- `NMC_v4_0.c2.dta`: COW National Material Capabilities Data Version 4.0, monadic 
- `polityiv.c1.dta`: Polity IV data, monadic
- `polityiv.c2.dta`: Polity IV data, monadic
- `thompson.rivalry.yearly.dta`: Thompson & Dreyer rivalry data
- `TM_WORLD_BORDERS_SIMPL-0.3`: Shape file for world map provided by Bjorn Sandvik, <http://www.thematicmapping.org>

# Instructions

## 1. Analyses of claims

To prepare the data for analysis, `claims_full.csv`:

- Execute `10_claims_createdata.R`
- Note: This step is not necessary because `claims_full.csv` is already part of the replication package. The code is provided to document the creation of the data used in the analyses.

To reproduce the analysis underlying Figure 1 only:

- Execute `11_claims_readdata.R`
- Execute `12_claims_figure1.R`

To reproduce all other analyses of claims shown in the SI (sections 11 and 12):

- Execute `11_claims_readdata.R`
- Execute `13_claims_analyses.R`
- For section 11.5, execute `14_claims_dy_analyses.R`
- For section 11.6, execute `15_claims_selection.do`

## 2. Analyses of crises

To prepare the data for analysis, `crises_full.csv`:

- Execute `20_crises_createdata.R`
- Note: This step is not necessary because `crises_full.csv` is already part of the replication package. The code is provided to document the creation of the data used in the analyses.

To reproduce the analysis underlying Figure 1 only:

- Execute `21_crises_readdata.R`
- Execute `22_crises_figure2.R`

To reproduce all other analyses of claims shown in the SI (sections 13 and 14):

- Execute `21_crises_readdata.R`
- Execute `23_crises_analyses.R`
- For section 13.4, execute `24_crises_coll_analyses.R`

## 3. Other analyses

To reproduce the figures in Section 10 of the SI:

- Execute `30_claims-crises_coefficients.R`

To reproduce the analyses in Section 15 of the SI:

- Execute `40_hligo_joint.R`

## 4. Descriptive information

To reproduce the figures in Section 4 of the SI:

- Execute `11_claims_readdata.R` and `21_crises_readdata.R`

To reproduce the figures in Section 5 of the SI:

- Execute `13_claims_analyses.R` and `23_crises_analyses.R`

To reproduce the figures in Section 6 of the SI:

- Execute `50_hligo_geo.R`

# List of files

The list below shows the complete file structure of this replication package. Note that the folders within the package (`Functions`, `Output_MCMC`, `Output_Tables-and-Figures`, `Sources`) are compressed in .zip format. These folders need to be extracted before proceeding. 

- On Mac OS X, open the Terminal, change to the `Replication` directory, and type `unzip Functions.zip` etc.
- On Windows, use an application such as [7-Zip](http://www.7-zip.org) to extract these folders.

```
Replication
|- 10_claims_createdata.R
|- 11_claims_readdata.R
|- 13_claims_analyses.R
|- 14_claims_dy_analyses.R
|- 15_claims_selection.do
|- 20_crises_createdata.R
|- 21_crises_readdata.R
|- 23_crises_analyses.R
|- 24_crises_coll_analyses.R
|- 30_claims-crises_coefficients.R
|- 40_hligo_joint.R
|- 50_hligo_geo.R
|- 60_hligo_time.R
|- claims_dyadyear.csv
|- claims_full.csv
|- claims_full.dta
|- claims_m-allothers_roc.stan
|- claims_m-ingr23_roc.stan
|- claims_m-mp3_roc.stan
|- claims_m-noigos_roc.stan
|- claims_m-pb_roc.stan
|- claims_m1_roc.stan
|- claims_m1.stan
|- claims_selection.csv
|- crises_full.csv
|- crises_full.dta
|- crises_m-allothers_roc.stan
|- crises_m-ingr23_roc.stan
|- crises_m-mp3_roc.stan
|- crises_m-noigos_roc.stan
|- crises_m-pb_roc.stan
|- crises_m1_roc.stan
|- Functions/
|  |- geom_flat_violin.R
|  |- MCMC_roc_prc.R
|  |- MCMClogit.fd.mat.R
|  |- plotBMA.R
|  |- theme_jk.R
|- hl-igo_dyad.dta
|- hligo_joint.csv
|- igo_overlap_num.csv
|- Output_MCMC/
|  |- claims_dy_m1.RDS
|  |- claims_dy_m2.RDS
|  |- claims_m1_allothers_rstan.RDS
|  |- claims_m1_ingr23_rstan.RDS
|  |- claims_m1_mp3_rstan.RDS
|  |- claims_m1_noigo_stanglm.RDS
|  |- claims_m1_noigos_rstan.RDS
|  |- claims_m1_pb_rstan.RDS
|  |- claims_m1_rstan.RDS
|  |- claims_m1_stanglm.RDS
|  |- claims_m2_stanglm.RDS
|  |- claims_m3_stanglm.RDS
|  |- claims_m4_stanglm.RDS
|  |- claims_m5_stanglm.RDS
|  |- claims_m6_stanglm.RDS
|  |- claims_m7_stanglm.RDS
|  |- claims_m8_stanglm.RDS
|  |- claims_m9_stanglm.RDS
|  |- claims_m10_stanglm.RDS
|  |- claims_m11_stanglm.RDS
|  |- claims_m12_stanglm.RDS
|  |- claims_m13_stanglm.RDS
|  |- claims_m14_stanglm.RDS
|  |- claims_m15_stanglm.RDS
|  |- claims_m16_stanglm.RDS
|  |- claims_nomult_hiviol_m1_stanglm.RDS
|  |- crises_m1_allothers_rstan.RDS
|  |- crises_m1_ingr23_rstan.RDS
|  |- crises_m1_mp3_rstan.RDS
|  |- crises_m1_noigos_rstan.RDS
|  |- crises_m1_pb_rstan.RDS
|  |- crises_m1_rstan.RDS
|  |- crises_m1_stanglm.RDS
|  |- crises_m2_stanglm.RDS
|  |- crises_m3_stanglm.RDS
|  |- crises_m4_stanglm.RDS
|  |- crises_m5_stanglm.RDS
|  |- crises_m6_stanglm.RDS
|  |- crises_m7_stanglm.RDS
|  |- crises_m8_stanglm.RDS
|  |- crises_m9_stanglm.RDS
|  |- crises_m10_stanglm.RDS
|  |- crises_m11_stanglm.RDS
|  |- crises_m12_stanglm.RDS
|  |- crises_m13_stanglm.RDS
|  |- crises_m14_stanglm.RDS
|  |- crises_m15_stanglm.RDS
|  |- crises_noclus_m1_stanglm.RDS
|  |- crises_nomult_hiviol_m1_stanglm.RDS 
|- Output_Tables-and-Figures/
|  |- [Tables and Figures will be generated here]
|- Sources:
|  |- atop3_0ddyr.dta
|  |- Dyadicdata.tab
|  |- icb1v11.csv
|  |- icbdy_v11.csv
|  |- ICOWclaimdy.dta
|  |- IGO_igounit_v2.3.narrow.csv
|  |- IGO_igounit_v2.3.short.csv
|  |- IGO_names_v2.3.csv
|  |- IGO_stateunit_v2.3.csv
|  |- igo.c1.diss.dta
|  |- igo.c2.diss.dta
|  |- igo.dyad.diss.dta
|  |- IGOpb_dyadunit.dta
|  |- igotrade.ud1918.dta
|  |- KGD_rivalry_yearly.dta
|  |- mtopsd150.dta
|  |- NMC_v4_0.c1.dta
|  |- NMC_v4_0.c2.dta
|  |- polityiv.c1.dta
|  |- polityiv.c2.dta
|  |- thompson.rivalry.yearly.dta
|  |- TM_WORLD_BORDERS_SIMPL-0.3/
|     |- Readme.txt
|     |- TM_WORLD_BORDERS_SIMPL-0.3.dbf
|     |- TM_WORLD_BORDERS_SIMPL-0.3.prj
|     |- TM_WORLD_BORDERS_SIMPL-0.3.shp
|     |- TM_WORLD_BORDERS_SIMPL-0.3.shx
```

# Software information

The `sessionInfo()` output below shows the versions of all R packages used in the analyses in this article.

```
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X El Capitan 10.11.6

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggrepel_0.6.5        maps_3.1.1           RColorBrewer_1.1-2   foreign_0.8-67      
 [5] rgdal_1.2-4          maptools_0.8-39      sp_1.2-3             pscl_1.4.9          
 [9] lattice_0.20-34      MASS_7.3-45          data.table_1.9.6     countrycode_0.18    
[13] caTools_1.17.1       ROCR_1.0-7           gplots_3.0.1         ggmcmc_1.1          
[17] tidyr_0.6.0          BMA_3.18.6           rrcov_1.3-11         inline_0.3.14       
[21] robustbase_0.92-6    leaps_2.9            survival_2.39-5      lme4_1.1-13         
[25] Matrix_1.2-7.1       loo_1.1.0            gridExtra_2.2.1      texreg_1.36.23      
[29] rstan_2.15.1         StanHeaders_2.15.0-1 reshape2_1.4.2       xtable_1.8-2        
[33] rstanarm_2.13.1      Rcpp_0.12.11         ggplot2_2.2.1        dplyr_0.5.0         
[37] rio_0.4.16          

loaded via a namespace (and not attached):
 [1] VGAM_1.0-2         minqa_1.2.4        colorspace_1.2-6   rsconnect_0.8     
 [5] markdown_0.8       base64enc_0.1-3    MatrixModels_0.4-1 urltools_1.6.0    
 [9] DT_0.2             mvtnorm_1.0-6      xml2_1.1.1         codetools_0.2-15  
[13] splines_3.3.2      shinythemes_1.1.1  bayesplot_1.2.0    Formula_1.2-1     
[17] jsonlite_1.5       nloptr_1.0.4       mcmc_0.9-4         pbkrtest_0.4-6    
[21] cluster_2.0.5      geepack_1.2-1      shiny_1.0.3        readr_1.0.0       
[25] assertthat_0.1     lazyeval_0.2.0     survey_3.30-3      htmltools_0.3.6   
[29] quantreg_5.26      tools_3.3.2        coda_0.19-1        gtable_0.2.0      
[33] cellranger_1.1.0   Amelia_1.7.4       gdata_2.17.0       nlme_3.1-128      
[37] lmtest_0.9-34      stringr_1.2.0      readODS_1.6.2      openxlsx_3.0.0    
[41] mime_0.5           miniUI_0.1.1       gtools_3.5.0       DEoptimR_1.0-8    
[45] zoo_1.8-0          scales_0.4.1       colourpicker_0.3   miscTools_0.6-16  
[49] parallel_3.3.2     sandwich_2.3-4     SparseM_1.7        shinystan_2.3.0   
[53] yaml_2.1.14        curl_2.3           triebeard_0.3.0    reshape_0.8.5     
[57] stringi_1.1.5      dygraphs_1.1.1.4   pcaPP_1.9-60       AER_1.2-4         
[61] gpclib_1.5-5       chron_2.3-47       matrixStats_0.52.2 bitops_1.0-6      
[65] rstantools_1.2.0   htmlwidgets_0.8    labeling_0.3       GGally_1.3.0      
[69] plyr_1.8.4         magrittr_1.5       R6_2.2.1           DBI_0.4-1         
[73] haven_1.0.0        mgcv_1.8-16        xts_0.9-7          nnet_7.3-12       
[77] tibble_1.2         csvy_0.1.3         car_2.1-2          KernSmooth_2.23-15
[81] maxLik_1.3-4       grid_3.3.2         readxl_0.1.1       threejs_0.2.2     
[85] digest_0.6.12      httpuv_1.3.3       Zelig_5.0-15       MCMCpack_1.3-6    
[89] MatchIt_2.4-21     stats4_3.3.2       munsell_0.4.3      shinyjs_0.9       
```